<!DOCTYPE html>
<html lang="cn" dir="ltr">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>增加信息</title>
    <link rel="icon" href="favicon.ico" type="image/x-icon">
    <link href="/static/css/reset.css" rel="stylesheet">
    <!-- Bootstrap3.3.5 CSS -->
    <link href="/static/css/bootstrap.min.css" rel="stylesheet">
    <link href="/static/css/login.css" rel="stylesheet">
    <link href="/static/css/queryResult.css" rel="stylesheet">
    <link href="/static/css/addEdu.css" rel="stylesheet">
</head>
<body>
<div class="container">
    <div class="queryResule">
        <h2>增加商品溯源信息</h2>
        <div class="back">
          {{if eq .CurrentUser.IsAdmin "T"}}
              <a href="/addEduInfo">添加信息</a>
          {{end}}
            <a href="/index">返回首页</a>
        </div>
        <form action="/modify" method="post" name="modifyForm">
        <div class="top">
              <div class="left">
                  <p>
                      <span>事件类型：</span>
                      <span>
                        <input type="text" name="docType" value="{{.Com.Type}}" class="input_text" tabindex="1" onfocus="if(this.placeholder=='事件类型'){this.placeholder='';}this.className ='input_text input_text_focus'" onblur="if(this.value==''){this.placeholder='事件类型';this.className ='input_text'}" accesskey="n" type="text" placeholder="事件类型" size="25" autocomplete="off">
                      </span>
                  </p>
                  <p>
                      <span>溯源编号：</span>
                      <span>
                        <input type="text" name="primarykey" value="{{.Com.Primarykey}}" class="input_text" tabindex="1" onfocus="if(this.placeholder=='溯源编号'){this.placeholder='';}this.className ='input_text input_text_focus'" onblur="if(this.value==''){this.placeholder='溯源编号';this.className ='input_text'}" accesskey="n" type="text" placeholder="溯源编号" size="25" autocomplete="off">
                      </span>
                  </p>
                  <p>
                      <span>商品名称：</span>
                      <span>
                        <input type="text" name="name" value="{{.Com.Name}}" class="input_text" tabindex="1" onfocus="if(this.placeholder=='商品名称'){this.placeholder='';}this.className ='input_text input_text_focus'" onblur="if(this.value==''){this.placeholder='商品名称';this.className ='input_text'}" accesskey="n" type="text" placeholder="商品名称" size="25" autocomplete="off">
                      </span>
                  </p>
                  <p>
                      <span>品牌：</span>
                      <span>
                        <input type="text" name="brand" value="{{.Com.Brand}}" class="input_text" tabindex="1" onfocus="if(this.placeholder=='品牌'){this.placeholder='';}this.className ='input_text input_text_focus'" onblur="if(this.value==''){this.placeholder='品牌';this.className ='input_text'}" accesskey="n" type="text" placeholder="品牌" size="25" autocomplete="off" placeholder="">
                      </span>
                  </p>
                  <p>
                      <span>描述：</span>
                      <span>
                        <input type="text" name="des" value="{{.Com.Des}}" class="input_text" tabindex="1" onfocus="if(this.placeholder=='描述'){this.placeholder='';}this.className ='input_text input_text_focus'" onblur="if(this.value==''){this.placeholder='描述';this.className ='input_text'}" accesskey="n" type="text" placeholder="描述" size="25" autocomplete="off">
                      </span>
                  </p>
                  <p>
                      <span>规格：</span>
                      <span>
                        <input type="text" name="specification" value="{{.Com.Specification}}" class="input_text" tabindex="1" onfocus="if(this.placeholder=='规格'){this.placeholder='';}this.className ='input_text input_text_focus'" onblur="if(this.value==''){this.placeholder='规格';this.className ='input_text'}" accesskey="n" type="text" placeholder="规格" size="25" autocomplete="off">
                      </span>
                  </p>
                  <p>
                      <span>商品来源：</span>
                      <span>
                        <input type="text" name="source" value="{{.Com.Source}}" class="input_text" tabindex="1" onfocus="if(this.placeholder=='商品来源'){this.placeholder='';}this.className ='input_text input_text_focus'" onblur="if(this.value==''){this.placeholder='商品来源';this.className ='input_text'}" accesskey="n" type="text" placeholder="商品来源" size="25" autocomplete="off">
                      </span>
                  </p>
                  <p>
                      <span>加工方式：</span>
                      <span>
                        <input type="text" name="machining" value="{{.Com.Machining}}" class="input_text" tabindex="1" onfocus="if(this.placeholder=='毕业/结业'){this.placeholder='';}this.className ='input_text input_text_focus'" onblur="if(this.value==''){this.placeholder='毕业/结业';this.className ='input_text'}" accesskey="n" type="text" placeholder="毕业/结业" size="25" autocomplete="off">
                      </span>
                  </p>
              </div>
              <div class="right">
                  <p>
                      <span>备注信息：</span>
                      <span>
                        <input type="text" name="remarks" value="{{.Com.Remarks}}" class="input_text" tabindex="1" onfocus="if(this.placeholder=='备注信息'){this.placeholder='';}this.className ='input_text input_text_focus'" onblur="if(this.value==''){this.placeholder='备注信息';this.className ='input_text'}" accesskey="n" type="text" placeholder="备注信息" size="25" autocomplete="off">
                      </span>
                  </p>
                  <p>
                      <span>负责人：</span>
                      <span>
                        <input type="text" name="principal" value="{{.Com.Principal}}" class="input_text" tabindex="1" onfocus="if(this.placeholder=='负责人'){this.placeholder='';}this.className ='input_text input_text_focus'" onblur="if(this.value==''){this.placeholder='负责人';this.className ='input_text'}" accesskey="n" type="text" placeholder="负责人" size="25" autocomplete="off">
                      </span>
                  </p>
                  <p>
                      <span>负责人电话：</span>
                      <span>
                        <input type="text" name="phoneNumber" value="{{.Com.PhoneNumber}}" class="input_text" tabindex="1" onfocus="if(this.placeholder=='负责人电话'){this.placeholder='';}this.className ='input_text input_text_focus'" onblur="if(this.value==''){this.placeholder='负责人电话';this.className ='input_text'}" accesskey="n" type="text" placeholder="负责人电话" size="25" autocomplete="off">
                      </span>
                  </p>
                  <p>
                      <span>保质期：</span>
                      <span>
                        <input type="text" name="shelfLife" value="{{.Com.ShelfLife}}" class="input_text" tabindex="1" onfocus="if(this.placeholder=='保质期'){this.placeholder='';}this.className ='input_text input_text_focus'" onblur="if(this.value==''){this.placeholder='保质期';this.className ='input_text'}" accesskey="n" type="text" placeholder="保质期" size="25" autocomplete="off">
                      </span>
                  </p>
                  <p>
                      <span>储藏方式：</span>
                      <span>
                        <input type="text" name="storageMethod" value="{{.Com.StorageMethod}}" class="input_text" tabindex="1" onfocus="if(this.placeholder=='储藏方式'){this.placeholder='';}this.className ='input_text input_text_focus'" onblur="if(this.value==''){this.placeholder='储藏方式';this.className ='input_text'}" accesskey="n" type="text" placeholder="储藏方式" size="25" autocomplete="off">
                      </span>
                  </p>
                  <p>
                      <span>生产厂商：</span>
                      <span>
                        <input type="text" name="vendor" value="{{.Com.Vendor}}" class="input_text" tabindex="1" onfocus="if(this.placeholder=='生产厂商'){this.placeholder='';}this.className ='input_text input_text_focus'" onblur="if(this.value==''){this.placeholder='生产厂商';this.className ='input_text'}" accesskey="n" type="text" placeholder="生产厂商" size="25" autocomplete="off">
                      </span>
                  </p>
                  <p>
                      <span>生产地：</span>
                      <span>
                        <input type="text" name="placeOfProduction" value="{{.Com.PlaceOfProduction}}" class="input_text" tabindex="1" onfocus="if(this.placeholder=='生产地'){this.placeholder='';}this.className ='input_text input_text_focus'" onblur="if(this.value==''){this.placeholder='生产地';this.className ='input_text'}" accesskey="n" type="text" placeholder="生产地" size="25" autocomplete="off">
                      </span>
                  </p>
                  <p>
                      <span>执行标准：</span>
                      <span>
                        <input type="text" name="executiveStandard" value="{{.Com.ExecutiveStandard}}" class="input_text" tabindex="1" onfocus="if(this.placeholder=='执行标准'){this.placeholder='';}this.className ='input_text input_text_focus'" onblur="if(this.value==''){this.placeholder='执行标准';this.className ='input_text'}" accesskey="n" type="text" placeholder="执行标准" size="25" autocomplete="off" placeholder="">
                      </span>
                  </p>
              </div>

            <div class="headImg">
                <div class="uploadImg">
                    <input type="file" name="" value="上传照片" id="file">
                    +
                    <!-- <img src="./images/head.jpg" alt=""> -->
                    <img src="{{.Com.Photo}}" alt="">
                </div>
                <p>上传照片(120*160px)</p>
            </div>
        </div>
        <input type="hidden" name="photo" id="photo" value="{{.Com.Photo}}"/>
        <button type="button" name="button" class="btn">增加商品信息</button>
        </form>
    </div>
    <!-- data-backdrop="false"去除遮罩层  -->
    <div class="modal fade bd-example-modal-sm"  id="myModal" role="dialog" data-backdrop="false"  aria-hidden="true">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <p class="text-center mb-0" style="height:42px;line-height:42px;margin:0;">
                    <i class="fa fa-check-circle text-success mr-1" aria-hidden="true"></i>
                    请输入商品所必需的相关信息
                </p>
            </div>
        </div>
    </div>

</div>
</body>
<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/js/bootstrap.min.js"></script>
<script type="text/javascript">
    $(function() {
        // 上传图片
        $('#file').unbind('change').bind('change',function() {
            event.stopPropagation();
            uploadFile('img');
            return;
        });
        // 头像图片
        var artImg;
        function uploadFile(type) {
            event.stopPropagation();
            let formData = new FormData();
            if( type == "img"){
                formData.append('file', $('#file')[0].files[0]);
            }
            $.ajax({
                url: '/upload',
                type: 'POST',
                cache: false,
                data: formData,
                processData: false,
                dataType: "json",
                contentType: false
            }).done(function (res) {
                if (res.error == "0") {
                    if( type == "img"){
                        $('.uploadImg img').attr('src', res.result.path);
                        $('#photo').val(res.result.path)
                        return artImg = res.result.path;
                    }
                } else {
                    alert("上传失败！" + res.result.msg)
                }
            }).fail(function (res) { });
        }

        var inputs = $('input[type="text"]');
        // 提交按钮
        $('.btn').click(function() {
            // 如果为空 报错提示
            for (var i = 0; i < inputs.length; i++) {
                if (!($(inputs[i]).val())) {
                    $(inputs[i]).addClass('redColor');
                    $('#myModal').modal('show');
                    setTimeout(function(){
                        $("#myModal").modal("hide");
                    },2000);
                    return;
                }
            }

            // 成功后提交数据
            $("form[name='modifyForm']").submit()
        })
    })
</script>
</html>
